package sk.xorty.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import sk.xorty.domain.Message;
import sk.xorty.service.MessageBoardService;

import java.util.List;

@Controller
@RequestMapping("/messageList*")
public class MessageListController {

    @Autowired MessageBoardService messageBoardService;

    @RequestMapping(method = RequestMethod.GET)
    public String generateList(Model model) {
        List<Message> messages = messageBoardService.listMessages();
        model.addAttribute("messages", messages);

        return "messageList";
    }
}
